function getNumberSameAsIndex(arr) {
    const length = arr.length;
    let left = 0,
        right = length - 1;
    let res = -1;
    while (left <= right) {
        let mid = (left + right) >> 1;
        if (arr[mid] == mid) {
            res = mid;
            break;
        }
        else if (arr[mid] < mid) {
            left = mid + 1;
        }
        else {
            right = mid - 1;
        }
    }
    return res;
}

arr = [-3, 1, 3, 4, 5];
console.log(getNumberSameAsIndex(arr));